package Reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class ReflectDemo3 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        Person p = new Person("wkk",22);
        System.out.println(p);

        Class cls = Class.forName("Reflect.Person");
        Constructor c1 = cls.getConstructor(String.class,int.class);
        Object object1 = c1.newInstance("wmm,",18);
        System.out.println(object1);

        Constructor c2 = cls.getConstructor(String.class);
        Object object2 = c2.newInstance("dxm");
        System.out.println(object2);
    }
}
